package com.dianxin.secure.persist;

import com.dianxin.secure.model.Secure;

import java.lang.reflect.Proxy;


public class RedisDaoProxy {
	
	public static RedisDaoInterface<Secure> createUserRedisDao() {
        Secure secure  =   Secure.user();
        return  createRedisDao(secure);
	}
	
	public static RedisDaoInterface<Secure> createGroupRedisDao() {
        Secure secure  =   Secure.group();
        return  createRedisDao(secure);
	}

    public static RedisDaoInterface<Secure> createRedisDao(Secure secure ) {
        RedisDao rediedao = new RedisDao();
        rediedao.setSecure(secure);
        RedieDaoHandler handler = new RedieDaoHandler(rediedao);
        @SuppressWarnings("unchecked")
        RedisDaoInterface<Secure> rediedaoProxy = (RedisDaoInterface<Secure>)Proxy.newProxyInstance(rediedao.getClass().getClassLoader(), RedisDao.class.getInterfaces(), handler);
        return rediedaoProxy;

    }

}
